/*
 * Filename PatientDetail.java 2021年09月28日
 * Copyright © Ehome Co.Ltd. All Rgiths Reserved.
 * @author wuyingchao
 */
package com.ehome.poct.core.api.dto.patient;

import cn.hutool.core.lang.Validator;
import com.ehome.poct.core.api.common.Age;
import com.ehome.poct.core.api.dto.common.AgeSegment;
import com.ehome.poct.core.api.dto.common.Sex;
import com.ehome.poct.core.api.dto.patient.PatientCategory;
import com.ehome.poct.core.api.vo.patient.PatientDetailVO;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * 患者信息 -值对象
 *
 * @author muqiu
 * @since 2022/03/04 15:31
 **/
@Getter
@NoArgsConstructor
public class PatientDetail {
    /**
     * 名字
     */
    private  String name;
    /**
     * 性别
     */
    private  Sex sex;
    /**
     * 手机号
     */
    private  String phone;
    /**
     * 年龄
     */
    private  Age age;



    public PatientDetail(String name, Sex sex, String phone, Age age) {
        Validator.validateNotEmpty(name, "未输入患者姓名！");
        Validator.validateNotNull(sex, "未输入患者性别！");
        this.name = name;
        this.sex = sex;
        this.phone = phone;
        this.age = age;
    }

    public PatientDetail(PatientDetailVO vo){
        Validator.validateNotEmpty(vo.getUserName(), "未输入患者姓名！");
        Validator.validateNotNull(vo.getUserSex(), "未输入患者性别！");
        this.name = vo.getUserName();
        this.sex = Sex.findByValue(vo.getUserSex());
        this.phone = vo.getMobilePhone();
        this.age = new Age(vo.getUserAge(),vo.getUserMonth());

    }

    public PatientCategory getCategory(int standard) {
        return PatientCategory.getItem(AgeSegment.getByAge(age, standard), sex);
    }
}
